﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ATEGo
{
    /// <summary>
    /// Result结果表的列名
    /// </summary>
    public enum ResultDTColumns
    {
        Index,
        CmdSuits,
        CmdTag,
        CmdIndex,
        Cmd,
        Result,
        Reason
    }

    /// <summary>
    /// 结果表
    /// </summary>
    public class ResultTable :DataTable
    {
        /// <summary>
        /// 重置结果表
        /// </summary>
        public new void Reset()
        {
            base.Reset();
            base.Rows.Clear();
            base.Columns.Clear();
            base.Clear();
            //增加列名
            foreach (var item in Enum.GetNames(typeof(ResultDTColumns)))
            {
                if (item == ResultDTColumns.Index.ToString())
                {
                    base.Columns.Add(item, typeof(int));
                }
                else
                {
                    base.Columns.Add(item, typeof(string));
                }
            }
        }

        /// <summary>
        /// Result表增加一个新行
        /// </summary>
        public void AddALine()
        {
            base.Rows.Add(base.Rows.Count);
        }

        /// <summary>
        /// 获取Result表刚刚插入的行
        /// </summary>
        public DataRow LastRow
        {
            get
            {
                return base.Rows[base.Rows.Count - 1];
            }
        }
    }
}